#{extends 'common/supervisor.html' /}
#{set title:'${model.comment}' /} 
 <div class="xn_c_content" style="width: 1084px;">
   <div class="xf_content_add">
   <div class="xfht_t_j_y_2">
   <!--右上-->
   <div class="xf_ht_obu_fklm">添加${model.comment}</div>
   <div class="xf_ht_news_content">
   <div class="xf_ht_news_content_t">
     <table border="0" cellspacing="0" cellpadding="0" class="xf_ht_news_content_t_t">
#foreach($field in $fieldList)
#if($field.isPk != "Y"&&${field.inputType}!="none")
#if(${field.inputType}=="textarea")
    <tr>
      <td align="right">${field.comment}：</td>
      <td><textarea class="xf_ht_jr_obttd_textarea" id="${field.field}" placeholder="请输入${field.comment}"></textarea></td>
    </tr>
#elseif(${field.inputType}=="date")
    <tr>
      <td align="right">${field.comment}：</td>
      <td><input class="xf_ht_jr_dfk_i_input" id="${field.field}" placeholder="请输入${field.comment}" onclick="laydate()" /></td>
    </tr>
#elseif(${field.inputType}=="datetime")
    <tr>
      <td align="right">${field.comment}：</td>
      <td><input class="xf_ht_jr_dfk_i_input" id="${field.field}" placeholder="请输入${field.comment}" onclick="laydate()" /></td>
    </tr>
#elseif(${field.inputType}=="file")
	<tr>
       <td align="right">${field.comment}：</td>
       <td>
        #{img src:"",id:"${field.field}src", name:"image",class:"xf_ht_rjsc_zlsz_img",alt:""}#{/img}
       </td>
     </tr>
     <tr>
       <td align="right" valign="top"><span class="xf_ht_lv"></span></td>
        <td style="padding-left: 180px;">
       <span style="position: relative;">&nbsp;&nbsp;
         <input class='upload_btn' type="button" value="上传图片"> &nbsp;&nbsp;
         <input type="file" class="upload_file" name="imgFile" id="${field.field}file" onchange="uploadImageType('${field.field}file','${field.field}src');" style="top: 0px;*top:21px !important;left: -70px;*left:10px !important;" />
       </span>
       <span style="color:#999;" id="imageResolution"></span>
       <input type="hidden" name="${field.field}" id="${field.field}" />
       </td>
     </tr>
#elseif(${field.inputType}=="htmleditor")
	<tr>
      <td align="right">${field.comment}：</td>
      <td>
      		<div class="xf_ht_news_conr">
              <textarea class="xf_ht_jr_obttd_textarea" id="${field.field}"></textarea>
            </div>
      </td>
    </tr>
#elseif(${field.inputType}=="select")
#if($field.inputValueMap)
	<tr>
      <td align="right">${field.comment}：</td>
      <td>
    	<select class="xfht_t_j_td_1_s" id="${field.field}" name="${field.field}">
            <option value="" >==请选择==</option>
#foreach($item in $field.inputValueMap.entrySet())
			<option value="$!{item.key}">$!{item.value}</option>
#end
          </select>
      </td>
    </tr>
#elseif($field.inputType == "select"&&${field.inputValueTwo} != "")
	<tr>
      <td align="right">${field.comment}：</td>
      <td>
    	<select class="xfht_t_j_td_1_s" id="${field.field}" name="${field.field}">
            <option value="" >==请选择==</option>
            #{ list ${field.field}_list} 
			<option value="${ _?.id}">${ _?.${field.inputValueTwo}}</option>
			#{/list}
          </select>
      </td>
    </tr>
#else
	<tr>
      <td align="right">${field.comment}：</td>
      <td>
    	<select class="xfht_t_j_td_1_s" id="${field.field}" name="${field.field}">
            <option value="" >==请选择==</option>
          </select>
      </td>
    </tr>
#end
#else
    <tr>
      <td align="right">${field.comment}：</td>
      <td><input id="${field.field}" class="xf_ht_jr_dfk_i_input" type="text" placeholder="请输入${field.comment}"></td>
    </tr>
#end
#end
#end
 
	  </table>
	  <div class="xf_ht_news_content_button" colspan="4">
      <input class="xf_ht_tcc_button_ok" type="button" value="确定" onClick="addSave()">
    </div>
    </div>
    </div>
    </div>
  </div>
  </div> 
<script type="text/javascript"> 
  
#foreach($field in $fieldList)
#if(${field.inputType}=="htmleditor")
    var ${field.field}Edit;
#end
#end
    KindEditor.ready(function(K) {
#foreach($field in $fieldList)
#if(${field.inputType}=="htmleditor")
      ${field.field}Edit = K.create('#${field.field}', {
         cssPath :"@{'public/javascripts/kindeditor-4.1.7/plugins/code/prettify.css'}",
         uploadJson : '@{FileUpload.uploadImage2()}',
      allowFileManager : true,
      allowUpload: true
      });
#end
#end
    });


  $(function() {
#foreach($field in $fieldList)
#if(${field.inputType}=="date")
     laydate.render({
		elem: '#${field.field}'
	});
#end
#if(${field.inputType}=="datetime")
     laydate.render({
		elem: '#${field.field}'
		,type: 'datetime'
	});
#end
#end
 
  });
 
  function addSave() { 
#foreach($field in $fieldList)
#if($field.isPk != "Y"&&${field.inputType}!="none")
#if(${field.inputType}=="file")
	var ${field.field} = $("#${field.field}src").attr("src");
	 $("#${field.field}").val($("#${field.field}src").attr("src"));
#elseif(${field.inputType}=="htmleditor")
	var ${field.field} = ${field.field}Edit.html();
  	${field.field} = replaceAllHTML(${field.field});
#else
	var ${field.field} = $("#${field.field}").val().trim();
#end
#if(!$field.nullable)
	if($("#${field.field}").val() == ''){
    layer.alert('${field.comment}不能为空'); 
      return;
    }
#end
#end
#end  
    $.ajax({
      url : "@{add()}",
      type : "POST",
      data : {
#foreach($field in $fieldList)
#if($field.isPk != "Y"&&${field.inputType}!="none")
	"${model.modelL}.${field.columnName}" : ${field.field},
#end
#end 
      },
      success : function(data) {
        layer.alert(data.msg,1);
        
        if (data.code == 0) {
          location.href="@{list()}";
        }
      },
      error : function() {
        layer.alert("对不起，出现错误!");
      }
    });
  }
  
</script>